﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#if !DOT_NET
using Windows.Foundation;

#endif

namespace StyleMVVM.Utilities
{
	internal static class AsyncHelper
	{
		public static IAsyncAction CreateAsyncAction()
		{
			Task newTask = new Task(() => { });

			newTask.RunSynchronously();

			return newTask.AsAsyncAction();
		}

		public static IAsyncOperation<T> NullAsyncOp<T>() where T : class
		{
			Task<T> newTask = new Task<T>(() => null);

			newTask.RunSynchronously();

			return newTask.AsAsyncOperation();
		}

		public static IAsyncOperation<T> ReturnAsyncOp<T>(T returnValue)
		{
			Task<T> newTask = new Task<T>(() => returnValue);

			newTask.RunSynchronously();

			return newTask.AsAsyncOperation();
		}
	}
}